/*     */ package com.qmsk.business.store.storedRule.controller;
/*     */ 
/*     */ import com.qmsk.business.store.storedRule.dao.StoredRuleDtlDao;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"storedRuleDtl"})
/*     */ public class StoredRuleDtlController
/*     */ {
/*  30 */   private static final Logger logger = Logger.getLogger(StoredRuleDtlController.class);
/*     */ 
/*     */   @Autowired
/*     */   private StoredRuleDtlDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/sentInfo/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOpt2ShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  40 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  42 */       Map params = new HashMap();
/*  43 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*  44 */       MapUtils.addToMap(params, "storedRuleId", 
/*  45 */         RequestUtils.getInt(request, "storedRuleId"));
/*     */ 
/*  47 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  48 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  50 */       logger.error(e);
/*  51 */       ResponseUtils.setErrorMsgResponse(
/*  52 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/ruleId/{ruleId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListRuleId(HttpServletRequest request, HttpServletResponse response, @PathVariable("ruleId") Long ruleId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  61 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  63 */       Map params = new HashMap();
/*  64 */       MapUtils.addToMap(params, "ruleId", ruleId);
/*  65 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  66 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  68 */       logger.error(e);
/*  69 */       ResponseUtils.setErrorMsgResponse(
/*  70 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  79 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  81 */       Map params = new HashMap();
/*  82 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*  83 */       MapUtils.addToMap(params, "ruleId", 
/*  84 */         RequestUtils.getInt(request, "ruleId"));
/*  85 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  86 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  88 */       logger.error(e);
/*  89 */       ResponseUtils.setErrorMsgResponse(
/*  90 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/*  98 */       Map params = new HashMap();
/*  99 */       MapUtils.addToMap(params, "id", id);
/* 100 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params);
/* 101 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 103 */       logger.error(e);
/* 104 */       ResponseUtils.setErrorMsgResponse(
/* 105 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 123 */       int nResult = 0;
/* 124 */       String sData = RequestUtils.getStringOfData(request);
/* 125 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/* 127 */       if ((p != null) && (p.isExistsInsertRows()))
/*     */       {
/* 129 */         nResult = this.dao.applyUpdates(p);
/* 130 */         if (nResult > 0)
/* 131 */           DbConnection.commit();
/*     */         else {
/* 133 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 137 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 138 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 139 */         response);
/*     */     } catch (Exception e) {
/* 141 */       logger.error(e);
/* 142 */       DbConnection.rollback();
/* 143 */       ResponseUtils.setErrorMsgResponse(
/* 144 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 145 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void editShopId_id(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("id") Long id)
/*     */   {
/*     */     try
/*     */     {
/* 164 */       int nResult = 0;
/* 165 */       String sData = RequestUtils.getStringOfData(request);
/* 166 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/* 168 */       for (int i = 0; i < p.getListUpdateRows().size(); ++i) {
/* 169 */         if (((GsonHeadOneRow)p.getListUpdateRows().get(i)).getValueOfName("id") == null) {
/* 170 */           ((GsonHeadOneRow)p.getListUpdateRows().get(i)).autoAddHeadData("id", id);
/*     */         }
/*     */       }
/* 173 */       if ((p != null) && (p.isExistsUpdateRows()))
/*     */       {
/* 175 */         nResult = this.dao.applyUpdates(p);
/* 176 */         if (nResult > 0)
/* 177 */           DbConnection.commit();
/*     */         else {
/* 179 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 183 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 184 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 185 */         response);
/*     */     } catch (Exception e) {
/* 187 */       logger.error(e);
/* 188 */       DbConnection.rollback();
/* 189 */       ResponseUtils.setErrorMsgResponse(
/* 190 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 191 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void editShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 209 */       int nResult = 0;
/* 210 */       String sData = RequestUtils.getStringOfData(request);
/* 211 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/* 213 */       for (int i = 0; i < p.getListUpdateRows().size(); ++i) {
/* 214 */         if (((GsonHeadOneRow)p.getListUpdateRows().get(i)).getValueOfName("id") == null) {
/* 215 */           ResponseUtils.setSqlResultResponse(nResult, 
/* 216 */             RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 217 */             response);
/* 218 */           return;
/*     */         }
/*     */       }
/* 221 */       if ((p != null) && (p.isExistsUpdateRows()))
/*     */       {
/* 223 */         nResult = this.dao.applyUpdates(p);
/* 224 */         if (nResult > 0)
/* 225 */           DbConnection.commit();
/*     */         else {
/* 227 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 231 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 232 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 233 */         response);
/*     */     } catch (Exception e) {
/* 235 */       logger.error(e);
/* 236 */       DbConnection.rollback();
/* 237 */       ResponseUtils.setErrorMsgResponse(
/* 238 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 239 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 255 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 257 */       String[] strParams = id.split(",");
/* 258 */       int nResult = this.dao.deleteParams(strParams);
/* 259 */       if (nResult > 0)
/* 260 */         DbConnection.commit();
/*     */       else {
/* 262 */         DbConnection.rollback();
/*     */       }
/* 264 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 265 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 266 */         response);
/*     */     } catch (Exception e) {
/* 268 */       DbConnection.rollback();
/* 269 */       logger.error(e);
/* 270 */       ResponseUtils.setErrorMsgResponse(
/* 271 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 272 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.storedRule.controller.StoredRuleDtlController
 * JD-Core Version:    0.5.3
 */